package com.ruoyi.business.service.impl;

import java.util.List;

import com.ruoyi.business.domain.TbGoodsList;
import com.ruoyi.business.mapper.TbGoodsListMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.TbGoodsDictMapper;
import com.ruoyi.business.domain.TbGoodsDict;
import com.ruoyi.business.service.ITbGoodsDictService;
import com.ruoyi.common.core.text.Convert;
import org.springframework.transaction.annotation.Transactional;

/**
 * 【请填写功能名称】Service业务层处理
 *
 * @author ruoyi
 * @date 2021-04-23
 */
@Service
public class TbGoodsDictServiceImpl implements ITbGoodsDictService {
    @Autowired
    private TbGoodsDictMapper tbGoodsDictMapper;

    @Autowired
    private TbGoodsListMapper tbGoodsListMapper;

    /**
     * 查询【请填写功能名称】
     *
     * @param id 【请填写功能名称】ID
     * @return 【请填写功能名称】
     */
    @Override
    public TbGoodsDict selectTbGoodsDictById(Long id) {
        return tbGoodsDictMapper.selectTbGoodsDictById(id);
    }

    /**
     * 查询【请填写功能名称】列表
     *
     * @param tbGoodsDict 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<TbGoodsDict> selectTbGoodsDictList(TbGoodsDict tbGoodsDict) {
        return tbGoodsDictMapper.selectTbGoodsDictList(tbGoodsDict);
    }

    /**
     * 新增【请填写功能名称】
     *
     * @param tbGoodsDict 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertTbGoodsDict(TbGoodsDict tbGoodsDict) {
        return tbGoodsDictMapper.insertTbGoodsDict(tbGoodsDict);
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param tbGoodsDict 【请填写功能名称】
     * @return 结果
     */
    @Override
    @Transactional
    public int updateTbGoodsDict(TbGoodsDict tbGoodsDict) {
        TbGoodsList tbGoodsList = new TbGoodsList();
        tbGoodsList.setGoodsId(tbGoodsDict.getId());
        tbGoodsList.setGoodsName(tbGoodsDict.getGoodsName());
        tbGoodsList.setManufacturer(tbGoodsDict.getManufacturer());
        tbGoodsList.setGoodsType(tbGoodsDict.getGoodsType());
        tbGoodsList.setBrand(tbGoodsDict.getBrand());
        tbGoodsList.setGoodsPrice(tbGoodsDict.getGoodsPrice());
        tbGoodsListMapper.updateTbGoodsListByGoodsId(tbGoodsList);
        return tbGoodsDictMapper.updateTbGoodsDict(tbGoodsDict);
    }

    /**
     * 删除【请填写功能名称】对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteTbGoodsDictByIds(String ids) {
        return tbGoodsDictMapper.deleteTbGoodsDictByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除【请填写功能名称】信息
     *
     * @param id 【请填写功能名称】ID
     * @return 结果
     */
    @Override
    public int deleteTbGoodsDictById(Long id) {
        return tbGoodsDictMapper.deleteTbGoodsDictById(id);
    }
}
